#include <iostream>
#include <vector>
using namespace std;
#define TOOLS

// =============== 全局方法&对象 ===============

void Swap(int &a, int &b)
{
    int temp = a;
    a = b;
    b = temp;
}

vector<int> testVector{5, 3, 4, 2, 5, 1, 7, 6};

template <typename T>
ostream &operator<<(ostream &cout, const vector<T> &v)
{
    for (auto elem : v)
        cout << elem << " ";
    return cout;
}

struct ListNode
{
    int val;
    ListNode *next;

    ListNode(int val) : val(val), next(nullptr) {}
};

ostream &operator<<(ostream &cout, const ListNode *head)
{
    const ListNode *p = head;
    while (p != nullptr)
    {
        if (p->next != nullptr)
            cout << p->val << " -> ";
        else
            cout << p->val;
        p = p->next;
    }
    return cout;
}

ostream &operator<<(ostream &cout, const ListNode &head)
{
    return ::operator<<(cout, &head);
}

struct BiTreeNode
{
    int val;
    BiTreeNode *lchild;
    BiTreeNode *rchild;

    BiTreeNode(int val) : val(val), lchild(nullptr), rchild(nullptr) {}
};

auto PrintFunction = [](int val) -> void
{
    cout << val << " ";
};

// 复杂链表
struct RandListNode
{
    int val;
    RandListNode* rand;
    RandListNode* next;

    RandListNode(int val) : val(val), rand(nullptr), next(nullptr) {}
};